var express = require("express");
var router = express.Router();
let upload = require("../utils/multer"); //上传的中间件
/* GET home page. */
router.get("/", function (req, res, next) {
  res.render("index", { title: "Express" });
});
//filename要和前端的名字相对应
router.post("/uploads", upload.array("filename"), (req, res) => {
  //如果图片上传成功  返回图片上传的地址
  res.json({
    code: 1,
    url: "/uploads/" + req.files[0].filename,
  });
});
module.exports = router;
